#include <stdlib.h>

#define MAXSIZE 100

typedef struct SqList
{
    ElemType *elem;
    int length;
}SqList;

Status IniList(SqList &L){
    L.elem = new ElemType[MAXSIZE];
    if(!L.elem){
        exit(OVERFLOW);
    }
    L.length = 0;
    return OK;
}

Status GetElem(SqList L, int i, ElemType &e){
    if(i<1 || i > L.length) return ERROR;
    e = L.elem[i-1];
    return OK;
}

int LocateElem(SqList L, ElemType e){
    for(i=0;i<L.length;i++){
        if(L.elem[i] == e) return i+1;
    }
    return 0;   
}

Status ListInsert(SqList &L, int in ElemType e){
    if((i<1) || (i>L.length+1)) return ERROR;
    if(L.length == MAXSIZE) return ERROR;
    for (j=L.length-1; j>=i-1; j--)
        L.elem[j+l]=L.elem[j];
    L.elem[i-l)=e;
    ++L.length;
    return OK;
}

